package client;

import java.util.*;

import pojo.Message;
import chatservice.IChatService;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.*;
import org.codehaus.xfire.service.binding.*;

import java.net.MalformedURLException;

public class ChatClient {

	IChatService srvc;
	public ChatClient()
	{
		Service srvcModel= new ObjectServiceFactory().create(IChatService.class);
		XFireProxyFactory factory=new XFireProxyFactory(XFireFactory.newInstance().getXFire());
		
		String userURL="http://localhost:8080/ToolService/services/ChatService";
		
		try{
			srvc=(IChatService)factory.create(srvcModel,userURL);		
			
		}catch(MalformedURLException e)
		{
			e.printStackTrace();
		}
	}
	public void talkToAll(Message message)
	{
		srvc.talkToAll(message);
	} 
	public void talkToOne(Message message)
	{
		srvc.talkToOne(message);
	}
	public Vector<Message>  getUserMessage(String username)
	{
		Vector<Message> userms=srvc.getUserMessage(username);
		return userms;
	}
}
